<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__CSS__/l-blog.css">
    <script src="__JS__/jquery.min.js"></script>
</head>
<body style="background-color: #FFFFFF;">
<div id="login_panel">
    <form id="login_pwd_form">
        <div class="layui-row">
            <div class="layui-row">
                <input class="layui-input" name="username" placeholder="用户名/邮箱">
            </div>
            <div class="layui-row">
                <input type="password" class="layui-input" name="password" placeholder="请输入密码">
            </div>
            <div class="layui-row">
                <div class="layui-col-xs7">
                    <input class="layui-input" name="captcha" id="captcha" placeholder="请输入验证码">
                </div>
                <div class="layui-col-xs5">
                    <img class="right" src="{:captcha_src()}" style="height: 38px;width: 108px;"
                         onclick="this.src='{:captcha_src()}?'+Math.random()">
                </div>
            </div>
            <div class="layui-row">
                <button type="button" class="layui-btn sign-btn" onclick="loginByPwd()">登录</button>
            </div>
            <div class="layui-row">
                <a href="" class="right">忘记密码？</a><span class="right">&nbsp;&nbsp;</span>
                <a href="javascript:loginShow();" class="right">邮箱登陆</a>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-xs4">
                <hr class="layui-bg-gray">
            </div>
            <div class="layui-col-xs4 text-center">
                其他登录方式
            </div>
            <div class="layui-col-xs4">
                <hr class="layui-bg-gray">
            </div>
        </div>
        <div class="layui-row">
            {include file="user/other_login_way"}
        </div>
    </form>
</div>
</body>
</html>
<script src="__STATIC__/layui/layui.all.js"></script>
<script src="__JS__/common.js"></script>
<script src="__JS__/l-blog.js"></script>
<script src="__JS__/check.js"></script>
<script>
    function loginByPwd() {
        let res = checkUsername($('input[name="username"]').val());
        if (true !== res) {
            parent.layer.msg(res);
            return false;
        }
        res = checkPwd($('input[name="password"]').val());
        if (true !== res) {
            parent.layer.msg(res);
            return false;
        }
        res = checkCaptcha($('input[name="captcha"]').val());
        if (true !== res) {
            parent.layer.msg(res);
            return false;
        }
        let formData = new FormData(document.getElementById('login_pwd_form'));
        res = ajax(formData, '{:url("user/loginByPwd",["_ajax"=>1])}', 'post');
        if (res) {
            let data = JSON.parse(res);
            if (data.code == 1) {
                parent.layer.msg('登陆成功', {icon: 1});
                setTimeout('parent.history.go(0)', 1500);
            } else {
                parent.layer.msg(data.msg);
            }
        }
    }
</script>